import { TypeOrmModuleOptions } from '@nestjs/typeorm';
import * as path from 'path';

export const ormConfig: TypeOrmModuleOptions = {
  type: 'mysql',
  host: process.env.DB_HOST || 'localhost',
  port: parseInt(process.env.DB_PORT, 10) || 3306,
  username: process.env.DB_USERNAME || 'root',
  password: process.env.DB_PASSWORD || 'root',
  database: process.env.DB_NAME || 'xiche',
  entities: [path.join(__dirname, '..', 'models', '*.entity{.ts,.js}')],
  synchronize: true, // 开发环境下使用，生产环境应关闭
  logging: true,
};
